package ucadminlogic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"go.uber.org/zap"
	"navi-mumbai/app/rpc/usercenter/internal/svc"
	"navi-mumbai/app/rpc/usercenter/pb"
	"navi-mumbai/common/utils"
	"navi-mumbai/common/xerr"
)

type DeleteApkConfigLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteApkConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteApkConfigLogic {
	return &DeleteApkConfigLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 删除活动设置
func (l *DeleteApkConfigLogic) DeleteApkConfig(in *pb.DeleteApkConfigReq) (*pb.DeleteApkConfigResp, error) {
	defer utils.RecoverPanic()

	err := l.svcCtx.UserApkConfigModel.Delete(l.ctx, in.Id)
	if err != nil {
		l.Logger.Errorf("err == ", zap.Error(err))
		return nil, xerr.NewGrpcErrCodeMsg(xerr.DbError, err.Error())
	}
	return &pb.DeleteApkConfigResp{}, nil
}
